import request from '@/utils/request';

const baseUri = '/repairRecord';

// 定义一个 repairRecordService 对象，用于处理维修记录的增删改查等操作
const repairRecordService = {
  // 根据条件查询维修记录列表
  list({ title, repairNum, status, page, limit }) {
    return request({
      url: `${baseUri}/list`,
      method: 'get',
      params: {
        title,
        repairNum,
        status,
        page,
        limit,
      },
    });
  },

  // 根据id查询维修记录
  find(id) {
    return request({
      url: `${baseUri}/find`,
      method: 'get',
      params: { id },
    });
  },

  // 查询所有维修记录
  findAll() {
    return request({
      url: `${baseUri}/findAll`,
      method: 'get',
    });
  },

  // 添加维修记录
  add(repairRecord) {
    return request({
      url: `${baseUri}/add`,
      method: 'post',
      data: repairRecord,
    });
  },

  // 更新维修记录
  update(repairRecord) {
    return request({
      url: `${baseUri}/update`,
      method: 'post',
      data: repairRecord, // 将 repairRecord 对象作为请求体传递
    });
  },

  // 批量添加维修记录
  batchAdd(repairRecords) {
    return request({
      url: `${baseUri}/batchAdd`,
      method: 'post',
      data: repairRecords, // 将 repairRecord 数组作为请求体传递
    });
  },

  // 批量更新维修记录
  batchUpdate(repairRecords) {
    return request({
      url: `${baseUri}/batchUpdate`,
      method: 'post',
      data: repairRecords,
    });
  },

  // 批量删除维修记录
  batchRemove(ids) {
    return request({
      url: `${baseUri}/batchRemove`,
      method: 'post',
      data: ids,
    });
  },

  // 根据资产报告编号查询维修记录详情
  findDetail({ assetReportNum, page, limit, assetCode, assetName, assetModel }) {
    return request({
      url: `${baseUri}/findDetail`,
      method: 'get',
      params: { assetReportNum, page, limit, assetCode, assetName, assetModel },
    });
  },

  // 根据维修记录编号查询维修记录
  findByRepairRecordNum(repairNum) {
    return request({
      url: `${baseUri}/findByRepairRecordNum`,
      method: 'get',
      params: {repairRecordNum: repairNum}
    });
  },
};

// 导出 repairRecordService 对象
export default repairRecordService;
